package com.blate.dogxiao.adapter;

import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.blate.dogxiao.bean.ConversationBean;
import com.blate.dogxiao.databinding.ItemConversationListBinding;
import com.bumptech.glide.Glide;

/**
 * @author Blate
 * Created in 2021/4/21
 */
public class ConversationListAdapter
        extends SimpleDataRecyclerViewAdapter<ConversationBean, ItemConversationListBinding> {

    @Override
    protected ItemConversationListBinding onCreateBinding(LayoutInflater inflater, ViewGroup parent, int viewType) {
        return ItemConversationListBinding.inflate(inflater, parent, false);
    }

    @Override
    public void onBindViewHolder(@NonNull SimpleDataHolder<ConversationBean, ItemConversationListBinding> holder, ConversationBean data) {
        Glide
                .with(holder.getBinding().civAvatar)
                .load(data.avatar)
                .into(holder.getBinding().civAvatar);
        holder.getBinding().tvNickname.setText(data.nickname);
        holder.getBinding().tvDatetime.setText(data.lastMsgTime);
        holder.getBinding().tvMessage.setText(data.lastMsg);
    }

}
